function displayBW(n) {
	for(var lact=1; lact<=2; lact++){
		var lacabs = (document.getElementById("bwAbs" + lact).value) * 1.0;
		var lacpct = (document.getElementById("bwPct" + lact).value) * 0.01;
		
		for(var mim=1; mim<=24; mim++){
			
			var val = Number(document.getElementById("bw"+lact+"_"+mim).value);
			
			val = val * (1 + lacpct);
			val = val + lacabs;
			
			document.getElementById("bwoutput" + lact + "_" + mim).innerHTML = val.toFixed(0);
		}
	}
}


//computing repro 
function displayReproResults(n) {
var concsea=new Array(12), heatsea=new Array(12);
var table=document.getElementById("myTable"+n);
var reproinput=new Array(2);
reproinput[1]=document.getElementById("reproinput1"),
reproinput[2]=document.getElementById("reproinput2");

var row=new Array(), cell=new Array(), day=new Array(), val=new Array(); 
var i,j,s1=0,s2=0;

for (i=1;i<13;i++)
{   
	concsea[i]=(document.getElementById('concsea'+i).value)*0.01;
		
	s1=s1+concsea[i]; 
	
	heatsea[i]=(document.getElementById('heatsea'+i).value)*0.01;
	s2=s2+heatsea[i];

}

var concseapct=(document.getElementById('concseapct').value)*0.01;
var concabs=(document.getElementById('concabs').value)*0.01; //here abs actually is pct
var heatseapct=(document.getElementById('heatseapct').value)*0.01;
var heatabs=(document.getElementById('heatabs').value)*0.01;
var concseaavg=s1/12;  
var heatseaavg=s2/12;

var def1=[33.8,37,36.7,36.4,35.8,35,34,33,31.5,30,28.4,26.5,24.3,22.7];
var def2=[55,55,55,55,55,55,55,55,55,55,55,55,55,55];

var rowlength=reproinput[n].rows.length; 
for( j = 0; j < 14; j++ ) {
	if(rowlength<15)
	row[j]=reproinput[n].insertRow(-1);
    cell[0]=reproinput[n].rows[j].insertCell(-1);
 
	 reproinput[n].rows[j].cells[0].innerHTML="<span style='font-size:12px;'>"+(j+3)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;</span>";
	    cell[1]=reproinput[n].rows[j].insertCell(-1);
	 var kids=reproinput[n].rows[j].cells[1].childNodes.length; //limit child num =1
	if(kids<1){

     var ip= document.createElement( 'input' );
	  
     ip.type = 'text';
	 ip.className='span1';
     ip.name = 'concmim'+j;
	 ip.id='concmim'+j;
	 ip.style.width="25px";
	 ip.style.fontSize="12px";
	 ip.style.height="15px";
	 ip.style.display="inline";
	 ip.style.padding="2px";
	 ip.style.margin="0px";

      if(n==1){
	 ip.setAttribute("onChange","displayReproResults(1);");
     ip.value = Math.round(def1[j]);}
	 else{
	 ip.setAttribute("onChange","displayReproResults(2);");
	 ip.value = Math.round(def2[j]);
	 }
	 
	 var percent=document.createElement('span'); 
	 percent.innerHTML="%";
	 var div=document.createElement('div');
	 div.appendChild(ip);
	 div.appendChild(percent);
    
    reproinput[n].rows[j].cells[1].appendChild(div);
	 }
     if(n==1)
	def1[j]=(document.getElementById('concmim'+j).value);
	else 
	def2[j]=(document.getElementById('concmim'+j).value);
}
	
	
	
rowlength=table.rows.length;  //limit table rows and columns;
for( j = 0; j <15; j++ ) {
	if(rowlength<16)
	row[j]=table.insertRow(-1);	

  for( i = 0; i < 15; i++ ){	
    
	 var collength=table.rows[j].cells.length;	
	 if(collength<16)
	cell[i]=table.rows[j].insertCell(-1);	
  }
  
if(n==1){
   if(j==0) { 
  table.rows[j].cells[0].innerHTML="<b>Month</b>&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[1].innerHTML="<b>Day</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[2].innerHTML="";
  table.rows[j].cells[3].innerHTML="<b>Jan</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[4].innerHTML="<b>Feb</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[5].innerHTML="<b>Mar</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[6].innerHTML="<b>Apr</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[7].innerHTML="<b>May</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[8].innerHTML="<b>Jun</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[9].innerHTML="<b>Jul</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[10].innerHTML="<b>Aug</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[11].innerHTML="<b>Sep</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[12].innerHTML="<b>Oct</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[13].innerHTML="<b>Nov</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[14].innerHTML="<b>Dec</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  
  } else {
   day[j]=(j+2-1)*30.4;
  table.rows[j].cells[0].innerHTML=j+2;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
 table.rows[j].cells[2].innerHTML="";
 

  for( i = 3; i < 15; i++ ){	
	val[i]=(concseapct*(def1[j-1]*0.01)*concsea[i-2]+(1-concseapct)*(def1[j-1]*0.01)*concseaavg)+concabs;
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]*100)+"%";
    }
 } 
  } //for table1
else {

 if(j==0) { 
  table.rows[j].cells[0].innerHTML="<b>Month</b>&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[1].innerHTML="<b>Day</b>&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[2].innerHTML="";
  table.rows[j].cells[3].innerHTML="<b>Jan</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[4].innerHTML="<b>Feb</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[5].innerHTML="<b>Mar</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[6].innerHTML="<b>Apr</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[7].innerHTML="<b>May</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[8].innerHTML="<b>Jun</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[9].innerHTML="<b>Jul</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[10].innerHTML="<b>Aug</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[11].innerHTML="<b>Sep</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[12].innerHTML="<b>Oct</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[13].innerHTML="<b>Nov</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[14].innerHTML="<b>Dec</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  
  } else {
   day[j]=(j+2-1)*30.4;
  table.rows[j].cells[0].innerHTML=j+2;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
  table.rows[j].cells[2].innerHTML="";
  
	 for( i = 3; i < 15; i++ ){	
	val[i]=(heatseapct*heatsea[i-2]*(def2[j-1]*0.01)+(1-heatseapct)*(def2[j-1]*0.01))+heatabs;
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]*100)+"%";
    }
 } 
 
}  //for table2
 
 
}	
}





// computing cull function
function displayCullResults(){

var cullsea=new Array();
var table=document.getElementById("myTable1");
var tableinput=document.getElementById("cullinput");

var row=new Array(), cell=new Array(), day=new Array(), val=new Array(); 
var i,j;

for (i=1;i<13;i++)
{ 
	cullsea[i]=(document.getElementById('cullsea'+i).value)*0.01;
}

var cseasonality=(document.getElementById('cseasonality').value)*0.01;

var cullpct=Number(document.getElementById('cullpct').value)*0.01;
var cullabs=Number(document.getElementById('cullabs').value)*0.01;
var cullseaavg=(document.getElementById('cullseaavg').value)*0.01;

var def=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];

var rowlength=tableinput.rows.length; 
for( j = 0; j < 24; j++ ) {
	if(rowlength<26)
	row[j]=tableinput.insertRow(-1);
    cell[0]=tableinput.rows[j].insertCell(-1); 
	  var kids=tableinput.rows[j].cells[0].childNodes.length; //limit child num =1
	if(kids<1){

     var ip= document.createElement( 'input' );
	  
     ip.type = 'text';
	 ip.className='span1';
     ip.name = 'cullmim'+j;
	 ip.id='cullmim'+j;
	 ip.style.width="25px";
	 ip.style.fontSize="12px";
	 ip.style.height="15px";
	 ip.style.display="inline";
	 ip.style.padding="2px";
	 ip.style.margin="0px";
	 ip.setAttribute("onChange","displayCullResults();");

     ip.value = Math.round(def[j]*10)/10;
	 
	 var percent=document.createElement('span'); 
	 percent.innerHTML="%";
	 var div=document.createElement('div');
	 div.appendChild(ip);
	 div.appendChild(percent);
    
     tableinput.rows[j].cells[0].appendChild(div);
	 }

	def[j]=Number(document.getElementById('cullmim'+(j+1)).value);
}



rowlength=table.rows.length; 

for( j = 0; j < 25; j++ ) {
	if(rowlength<26)
	row[j]=table.insertRow(-1);

  for( i = 0; i < 15; i++ ){	
 
     var collength=table.rows[j].cells.length;
	 if(collength<16)
	cell[i]=table.rows[j].insertCell(-1);	
  }
  
   if(j==0) { 
  table.rows[j].cells[0].innerHTML="<b>Month</b>&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[1].innerHTML="<b>Day</b>&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[2].innerHTML=""
  table.rows[j].cells[3].innerHTML="<b>Jan</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[4].innerHTML="<b>Feb</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[5].innerHTML="<b>Mar</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[6].innerHTML="<b>Apr</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[7].innerHTML="<b>May</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[8].innerHTML="<b>Jun</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[9].innerHTML="<b>Jul</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[10].innerHTML="<b>Aug</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[11].innerHTML="<b>Sep</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    table.rows[j].cells[12].innerHTML="<b>Oct</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[13].innerHTML="<b>Nov</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[14].innerHTML="<b>Dec</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  
  } else {
   day[j]=(j-1)*30.4+15.2;
  table.rows[j].cells[0].innerHTML=j;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
  table.rows[j].cells[2].innerHTML="";
 /* var kids=table.rows[j].cells[2].childNodes.length; 
	if(kids<1){

     var ip= document.createElement( 'input' );
	  
     ip.type = 'text';
	 ip.className='span1';
     ip.name = 'cullmim'+j;
	 ip.id='cullmim'+j;
	 ip.style.width="25px";
	 ip.style.fontSize="12px";
	 ip.style.height="15px";
	 ip.style.display="inline";
	 ip.style.padding="2px";
	 ip.style.margin="0px";
	 ip.setAttribute("onChange","displayCullResults();");

     ip.value = Math.round(def[j-1]*10)/10;
	 
	 var percent=document.createElement('span'); 
	 percent.innerHTML="%";
	 var div=document.createElement('div');
	 div.appendChild(ip);
	 div.appendChild(percent);
    
     table.rows[j].cells[2].appendChild(div);
	 }

	def[j-1]=(document.getElementById('cullmim'+j).value);
*/

  for( i = 3; i < 15; i++ ){	
	val[i]=(cseasonality*(def[j-1]*0.01)*cullsea[i-2]+(1-cseasonality)*(def[j-1]*0.01)*cullseaavg+cullabs)*(1+cullpct);
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]*100*10)/10+"%";
    }
 } 
}

	
}


//computing milk

function selectCurve(){
	
var parent=document.getElementById("accordion2");

var childOne=document.getElementById("collapseOne");
var childTwo=document.getElementById("collapseTwo");
var childThree=document.getElementById("collapseThree");
var childFour=document.getElementById("collapseFour");


var switchcase;

if( $('#collapseOne').hasClass('in') ){
if(childTwo!=null)childTwo.parentNode.removeChild(childTwo);
if(childThree!=null)childThree.parentNode.removeChild(childThree);
if(childFour!=null)childFour.parentNode.removeChild(childFour);
switchcase=1;   //computing for wood's curve
}
else if( $('#collapseTwo').hasClass('in') ){
if(childOne!=null)childOne.parentNode.removeChild(childOne);
if(childThree!=null)childThree.parentNode.removeChild(childThree);
if(childFour!=null)childFour.parentNode.removeChild(childFour);
switchcase=2;   //computing for Fit curve
}
else if( $('#collapseThree').hasClass('in') ){
if(childTwo!=null)childTwo.parentNode.removeChild(childTwo);
if(childOne!=null)childOne.parentNode.removeChild(childOne);
if(childFour!=null)childFour.parentNode.removeChild(childFour);
switchcase=3;
}
else if( $('#collapseFour').hasClass('in') ){
if(childTwo!=null)childTwo.parentNode.removeChild(childTwo);
if(childThree!=null)childThree.parentNode.removeChild(childThree);
if(childOne!=null)childOne.parentNode.removeChild(childOne);
switchcase=4;
}
//alert(switchcase);	
return switchcase;	

}




function displayResults(n){
	
var units=document.getElementById('units').value;
var lbs;
var i,j,x;
var msea=new Array(3);
msea[1]=new Array(12), msea[2]=new Array(12),msea[3]=new Array(12);

var pct=new Array(3), mabs=new Array(3);

if (units=='kg') lbs=1;
else lbs=2.20462262;

//get msea1 to msea12

for (i=1;i<13;i++)
{
	msea[1][i]=(document.getElementById('msea1_'+i).value)*0.01;
	msea[2][i]=(document.getElementById('msea2_'+i).value)*0.01;
	msea[3][i]=(document.getElementById('msea3_'+i).value)*0.01;
}

for(i=1;i<4;i++){
	pct[i]=(document.getElementById('pct'+i).value)*0.01;
    mabs[i]=(document.getElementById('mabs'+i).value)*1;
}

var mseasonality=(document.getElementById('mseasonality').value)*0.01;
var mseaavg=(document.getElementById('mseaavg').value)*0.01;


var woodUserA=new Array(), woodUserB=new Array(), woodUserC=new Array(), woodCalcA=new Array(), woodCalcB=new Array(), woodCalcC=new Array(), _fit=new Array(), lactinput=new Array(3); lactinput[1]=new Array(24),lactinput[2]=new Array(24), lactinput[3]=new Array(24);

//var myswitchcase=selectCurve();  //other three curves are hidden
//var myswitchcase=1;
	
var table=document.getElementById("myTable"+n);

for(i=1;i<25;i++){

lactinput[1][i]=document.getElementById("lact1"+"_"+i);
lactinput[2][i]=document.getElementById("lact2"+"_"+i);
lactinput[3][i]=document.getElementById("lact3"+"_"+i);

}

var row=new Array(), cell=new Array(), day=new Array(), val=new Array(), rowlength=new Array(); 
var i,j;

//rowlength[n]=document.getElementById("myTable"+n).rows.length;

//switch(myswitchcase){
//case 1: //begin

  for (i=1;i<4;i++)
{
	woodUserA[i]=document.getElementById('wooda'+i).value;
	woodUserB[i]=document.getElementById('woodb'+i).value;
	woodUserC[i]=document.getElementById('woodc'+i).value/100;
}

  for (i=1;i<4;i++)
{
	//woodCalcA[i]=woodUserA[i];
	//woodCalcB[i]=woodUserB[i];
	//woodCalcC[i]=woodUserC[i];
	woodCalcA[i]=processWoodA(woodUserA[i], woodUserB[i], woodUserC[i]);
	woodCalcB[i]=processWoodB(woodUserB[i], woodUserC[i]);
	woodCalcC[i]=processWoodC(woodUserB[i], woodUserC[i]);
}
  
  
  
var rowlength=table.rows.length;



  for( j = 0; j < 25; j++ ) {
	  if (rowlength<26)
	row[j]=table.insertRow(-1);
	

  for( i = 0; i < 14; i++ ){
	 var collength=table.rows[j].cells.length;	
     if(collength<15)
	cell[i]=table.rows[j].insertCell(-1);	
  }
  

  if(j==0) { 
  
  table.rows[j].cells[0].innerHTML="<b>Month</b>&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[1].innerHTML="<b>Day</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[2].innerHTML="<b>Jan</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[3].innerHTML="<b>Feb</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[4].innerHTML="<b>Mar</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[5].innerHTML="<b>Apr</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[6].innerHTML="<b>May</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[7].innerHTML="<b>Jun</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[8].innerHTML="<b>Jul</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[9].innerHTML="<b>Aug</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[10].innerHTML="<b>Sep</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[11].innerHTML="<b>Oct</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[12].innerHTML="<b>Nov</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  table.rows[j].cells[13].innerHTML="<b>Dec</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  
   }else {
  day[j]=(j-1)*30.4+15.2;  
  table.rows[j].cells[0].innerHTML=j;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
    
//msea index is from 1 to 12 , so is i-1	
//n is the lactation times get when the function is called
  var s=0, avg=0;
  for( i = 2; i < 14; i++ ){	
	//val[i]=((mseasonality*(woodCalcA[n]*(Math.pow(day[j],woodCalcB[n]))*Math.exp(-woodCalcC[n]*day[j])*msea[n][i-1])+(1-mseasonality)*(woodCalcA[n]*(Math.pow(day[j],woodCalcB[n]))*Math.exp(-woodCalcC[n]*day[j])*mseaavg)))*(1+pct[n])*lbs+mabs[n];
	//val[i]=				((mseasonality*(woodCalcA[n]*					(Math.pow(day[j],woodCalcB[n]))*			Math.exp(-woodCalcC[n]*day[j])*				msea[n][i-1])+(1-mseasonality)*		(woodCalcA[n]*					(Math.pow(day[j],woodCalcB[n]))*			Math.exp(-woodCalcC[n]*day[j])*mseaavg)))*				(1+pct[n])*		lbs+mabs[n];
	//mlk[lact][mim][sea] = ((mSeasonality * woodsCalc.getLactA()[lact] * Math.pow(days, woodsCalc.getLactB()[lact]) * Math.exp(-woodsCalc.getLactC()[lact] * days) * mSea[sea]) + ((1 - mSeasonality) * woodsCalc.getLactA()[lact] * Math.pow(days, woodsCalc.getLactB()[lact]) * Math.exp(-woodsCalc.getLactC()[lact] * days) * mSeaAvg)) * (1 + mPct) * lbs + mAbs;

	val[i] = woodCalcA[n] * Math.pow(day[j]/30.4, woodCalcB[n]) * Math.exp((-1 * woodCalcC[n]) * (day[j]/30.4));
	val[i] = val[i] * msea[n][i-1];
	val[i] = val[i] * (1 + pct[n]);
	val[i] = val[i] + mabs[n];
	s=s+val[i];
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]);  
    }
	avg=s/12;
	lactinput[n][j].innerHTML=Math.round(avg);
	
  }
 } //end of case 1
//case 2:
 //computing fit curve;
/* for (i=1;i<10;i++)
{
	_fit[i]=document.getElementById('_fit'+i).value;

}
var temp1=new Array(), temp2=new Array(), temp3=new Array(), _wb=new Array(),a=new Array(), b=new Array(), c=new Array(), temp=new Array();

for (i=1;i<4;i++){
_wb[i]=document.getElementById('_wb'+i).value;
}

if(Math.pow(_fit[2+(n-1)*3],_wb[n])>_fit[2+(n-1)*3]) temp1[n]=1;
else if(Math.pow(_fit[2+(n-1)*3],_wb[n])<=0) temp1[n]=0.0001;
else temp1[n]=Math.pow(_fit[2+(n-1)*3],_wb[n]);
//alert(temp1);
if(Math.exp(-_wb[n])<=0) temp2[n]=0.0001;
else temp2[n]=Math.exp(-_wb[n]);
//alert(temp2);
temp3[n]=_fit[1+(n-1)*3]/(temp1[n]*temp2[n]);


if(temp3[n]<0) a[n]=0;
else if(temp3[n]>100) a[n]=100;
else a[n]=temp3[n];

if(_wb[n]<0||_wb[n]>1) b[n]=1;
else b[n]=_wb[n];

if((_wb[n]/_fit[2+(n-1)*3])>1) c[n]=1;
else if((_wb[n]/_fit[2+(n-1)*3])<0) c[n]=0;
else c[n]=_wb[n]/_fit[2+(n-1)*3];


for( j = 1; j < 25; j++ ) {
	row[j]=table.insertRow(-1);
	day[j]=(j-1)*30.4+15.2;
	temp[j]=a[n]*Math.pow(day[j],b[n])*Math.exp(-c[n]*day[j]);
	

  for( i = 0; i < 14; i++ ){	
 
	cell[i]=table.rows[j].insertCell(-1);	
  }

  table.rows[j].cells[0].innerHTML=j;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
    


  for( i = 2; i < 14; i++ ){	
val[i]=(mseasonality*temp[j]*msea[i-1]+(1-mseasonality)*temp[j]*mseaavg)*(1+pct)+mabs;
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]*100)/100;

  }
 
}*/

//case 3:// creating Florida curves
/*for( j = 1; j < 25; j++ ) {
	row[j]=table.insertRow(-1);
	day[j]=(j-1)*30.4+15.2;
	

  for( i = 0; i < 14; i++ ){	
 
	cell[i]=table.rows[j].insertCell(-1);	
  }

  table.rows[j].cells[0].innerHTML=j;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
    


  for( i = 2; i < 14; i++ ){	
val[i]=(mseasonality*myTableArray[n][j][i-2]*msea[i-1]+(1-mseasonality)*myTableArray[n][j][12]+mabs)*(1+pct)*lbs;
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]*100)/100;
  }
 
}

case 4:
var dp_1a=[], dp_1b=[],dp_1c=[],dp_2a=[],dp_2b=[],dp_2c=[], temp=[];

for (i=1;i<4;i++){
dp_1a[i]=document.getElementById('dp'+i+'_1a').value;
dp_1b[i]=document.getElementById('dp'+i+'_1b').value;
dp_1c[i]=document.getElementById('dp'+i+'_1c').value;
dp_2a[i]=document.getElementById('dp'+i+'_2a').value;
dp_2b[i]=document.getElementById('dp'+i+'_2b').value;
dp_2c[i]=document.getElementById('dp'+i+'_2c').value;
}


for( j = 1; j < 25; j++ ) {
	
	row[j]=table.insertRow(-1);
	day[j]=(j-1)*30.4+15.2;
	
	var pos1=Math.exp(dp_1b[n]*(day[j]-dp_1c[n]));
    var neg1=Math.exp(-(dp_1b[n]*(day[j]-dp_1c[n])));
    var v1=(pos1-neg1)/(pos1+neg1);
	var pos2=Math.exp(dp_2b[n]*(day[j]-dp_2c[n]));
    var neg2=Math.exp(-(dp_2b[n]*(day[j]-dp_2c[n])));
    var v2=(pos2-neg2)/(pos2+neg2);
	
    temp[j]=dp_1a[n]*dp_1b[n]*(1-Math.pow(v1,2))+dp_2a[n]*dp_2b[n]*(1-Math.pow(v2,2));
	

  for( i = 0; i < 14; i++ ){	
 
	cell[i]=table.rows[j].insertCell(-1);	
  }

  table.rows[j].cells[0].innerHTML=j;
  table.rows[j].cells[1].innerHTML=Math.round(day[j]);
    

  for( i = 2; i < 14; i++ ){	
val[i]=((mseasonality*temp[j]*msea[i-1]+(1-mseasonality)*temp[j]*mseaavg)*(1+pct)*lbs)+mabs;
	
   table.rows[j].cells[i].innerHTML=Math.round(val[i]*100)/100;
  } 
}
*/

//}
 
}


function processWoodA(woodUserA, woodUserB, woodUserC){
	var woodC = processWoodC(woodUserB, woodUserC);
	var woodB = processWoodB(woodUserB, woodUserC);
	var result = Number(woodUserA) * Math.pow((Number(woodC)/Number(woodB)) , Number(woodB)) * Math.exp(Number(woodB));
	return result;
}

function processWoodB(woodUserB, woodUserC){
	var woodC = processWoodC(woodUserB, woodUserC);
	var result = Number(woodC) * (Number(woodUserB)/30.4);
	return result;
}

function processWoodC(woodUserB, woodUserC){
	var result = (-1 * Number(woodUserC)) * ((Number(woodUserB) + 305)/(Number(woodUserB) - 305));
	return result;
}